package com.imooc.business.config;

import com.imooc.business.util.DateUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;

import java.util.Date;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
@Configuration
public class DateConveterConfig {
    @Bean
    public Converter<String, Date> dateConverter() {
        //亲测，这里不能用lambda表达式简化
        return new Converter<>() {
            @Override
            public Date convert(String source) {
                return DateUtil.parseNormalDate(source);
            }
        };
    }
}
